package com.smedi.ismedi.inmail.core.application.service.impl;

import com.smedi.ismedi.inmail.core.application.command.LoginLogLoginCommand;
import com.smedi.ismedi.inmail.core.application.command.LoginLogLogoutCommand;
import com.smedi.ismedi.inmail.core.application.convert.AppConverter;
import com.smedi.ismedi.inmail.core.application.service.LoginLogApplicationService;
import com.smedi.ismedi.inmail.core.domain.aggregatemodel.LoginLog;
import com.smedi.ismedi.inmail.core.domain.service.LoginLogDomainService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 通知公告应用服务实现类
 *
 * @author jiangqinxuan
 * @date 2021/07/26
 */
@Service
@RequiredArgsConstructor
@Transactional
@Slf4j
public class LoginLogApplicationServiceImpl implements LoginLogApplicationService {

    private final LoginLogDomainService loginLogDomainService;
    private final AppConverter appConverter;

    @Override
    public Long login(LoginLogLoginCommand loginLogLoginCommand) {
        LoginLog loginLog = appConverter.loginLogLoginCommandToLoginLog(loginLogLoginCommand);
        return loginLogDomainService.create(loginLog);
    }

    @Override
    public void logout(LoginLogLogoutCommand loginLogLogoutCommand) {
        LoginLog loginLog = appConverter.loginLogLogoutCommandToLoginLog(loginLogLogoutCommand);
        loginLogDomainService.update(loginLog);
    }
}
